function [pi d] = Calculate_pi_weekend_function(cum_Dtime_j_14)

global epsilon_weekend kappa ncity H_R E_weekend w d_GIS delta_j delta_t

d_GIS(:,26)=0;
cum_Dtime_j_14(26)=0; % home sector

cum_Dtime_t_14(:,1)=ones(25,1)*sum(cum_Dtime_j_14);
cum_Dtime_t_14(26,1)=0; % home sector

% Calculate top places to visit during weekdays and weekends
cum_Vtime_j_14=Calculate_V_function(cum_Dtime_j_14);
cum_Vtime_j_14(26)=0;

for a=1:2
    for d1=1:ncity
        for d2=1:ncity+1
            d(d1,d2,a)=exp(kappa*d_GIS(d1,d2)+delta_j(3,a)*log(cum_Dtime_j_14(d2)+1)+delta_j(4,a)*log(cum_Vtime_j_14(d2)+1)+delta_t(2,a)*log(cum_Dtime_t_14(d2)+1));
        end
    end
end
    for a=1:2
    for d1=1:ncity % given residential choice
        % calculate sum
        sum_denominator=0;
        for d2=1:ncity+1
            sum_denominator=sum_denominator+E_weekend(d2,a)*(1/d(d1,d2,a))^epsilon_weekend;
        end
        for d2=1:ncity+1
            pi(d1,d2,a)=E_weekend(d2,a)*(1/d(d1,d2,a))^epsilon_weekend/sum_denominator;
        end
    end
    end
end